﻿<UserControl x:Class="BeeCoders.Tools.Wpf.FileExplorer.FileExplorer"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:vm="clr-namespace:BeeCoders.Tools.Wpf.FileExplorer"
			 xmlns:Infrastructure="clr-namespace:BeeCoders.Tools.Wpf.Infrastructure" mc:Ignorable="d" 
			 d:DataContext="{d:DesignInstance vm:FileExplorerDemo, IsDesignTimeCreatable=True}"
			 d:DesignHeight="300" d:DesignWidth="300">
	<UserControl.Resources>
		<BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>
	</UserControl.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="30" />
			<RowDefinition Height="278*" />
		</Grid.RowDefinitions>
		<CheckBox IsChecked="{Binding IsFtpExplorer}" Grid.Row="0" Content="Ftp"></CheckBox>
		<TreeView Name="directoryView" 
				  ItemsSource="{Binding Instance.Drives}" Grid.Row="1">

			<TreeView.ItemContainerStyle>
				<Style TargetType="{x:Type TreeViewItem}">
					<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
					<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
					<Setter Property="FontWeight" Value="Normal" />
					<Style.Triggers>
						<Trigger Property="IsSelected" Value="True">
							<Setter Property="FontWeight" Value="Bold" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</TreeView.ItemContainerStyle>

			<TreeView.ItemTemplate>
				<HierarchicalDataTemplate ItemsSource="{Binding Path=Childs}">
					<Grid>
						<StackPanel Orientation="Horizontal">
							<CheckBox IsChecked="{Binding IsChecked}" Padding="4,0" Visibility="{Binding HasCheckbox,Converter={StaticResource BoolToVisConverter}}" VerticalAlignment="Center"></CheckBox>
							<Image Name="img" VerticalAlignment="Center" Width="24" Height="24" Stretch="Fill" Source="{Binding ImageName}" Visibility="{Binding ShowIcons,Converter={StaticResource BoolToVisConverter}}"></Image>
							<TextBlock VerticalAlignment="Center" Padding="4,0" Text="{Binding Name}"/>
						</StackPanel>
					</Grid>
				</HierarchicalDataTemplate>

			</TreeView.ItemTemplate>
		</TreeView>


	</Grid>
</UserControl>
